package com.sz.icbc.service.impl;

import com.sz.icbc.dao.AccountDao;
import com.sz.icbc.entity.Account;
import com.sz.icbc.service.AccountService;

import com.sz.icbc.vo.Transfer;
import com.sz.icbc.vo.TransferInfoVO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service

public class AccountServiceImpl implements AccountService {
    @Autowired
    AccountDao accountDao;
    @Transactional
    public String modifyAccount(TransferInfoVO transfer) {
        System.out.println(transfer.getToAccName());
        Account account = accountDao.getAccount(transfer.getToAccName());
        if(account == null){
            return "NOT_FIND_ACC";
        }
        String accin = transfer.getToAccNo();

        Double balance = transfer.getAccMoney().doubleValue();
        System.out.println(accin+"---"+balance);
        int temp =accountDao.modifyAccount(accin,balance);
        System.out.println(temp+"===");

       /* if(balance==5.0) {
            throw new RuntimeException("ahahhaha");
        }*/
        return "SUCCESS";

    }

}
